/**
 * tzdesk系统平台
 * moonvip_admin
 * com.tz.service.diamondparmcalculation
 * IDiamondParmCalculationService.java
 * 创建人:小胡
 * 时间：2017年03月03日 13:45:23
 *
 */
package com.tz.service.diamondparmcalculation.impl;
import com.tz.bean.DiamondParmCalculation;
import com.tz.bean.TzParams;
import com.tz.dao.diamondparmcalculation.IDiamondParmCalculationMapper;
import com.tz.service.diamondparmcalculation.IDiamondParmCalculationService;
import com.tz.util.TmStringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

/**
 * 钻石估价参数管理serviceImpl
 * IDiamondParmCalculationService
 * 创建人:小胡
 * 时间：2017年03月03日 13:45:23
 * @version 1.0.0
 *
 */
@Service
public class DiamondParmCalculationServiceImpl implements IDiamondParmCalculationService{

	@Autowired
	private IDiamondParmCalculationMapper diamondparmcalculationMapper;

	@Override
	public List<HashMap<String, Object>> findDiamondParmCalculations(TzParams params){
		if(TmStringUtils.isEmpty(params.getOrder()))params.setOrder("dc.weightlevel ,d.type desc,d.spec ,d.create_time desc");
		return diamondparmcalculationMapper.findDiamondParmCalculations(params);
	}

	@Override
	public int count(TzParams params) {
		return diamondparmcalculationMapper.count(params);
	}

	@Override
	public HashMap<String ,Object> getDiamondParmCalculation(Integer id) {
		return diamondparmcalculationMapper.getDiamondParmCalculation(id);
	}

	@Override
	public int save(DiamondParmCalculation diamondparmcalculation) {
		int n = diamondparmcalculationMapper.getSameCount(diamondparmcalculation);
		if(n>0){
			return  0;
		} else{
			return diamondparmcalculationMapper.save(diamondparmcalculation);
		}
	}

	@Override
	public int update(DiamondParmCalculation diamondparmcalculation) {
		int id = diamondparmcalculationMapper.getSameCountId(diamondparmcalculation);
		if(id != diamondparmcalculation.getId()){
			return  0;
		} else{
			return diamondparmcalculationMapper.update(diamondparmcalculation);
		}
	}

	@Override
	public int delete(TzParams params) {
		return diamondparmcalculationMapper.delete(params);
	}

	@Override
	public List<HashMap<String, Object>> getAllLevel() {
		return diamondparmcalculationMapper.getAllLevel();
	}

	public List<HashMap<String, Object>> getAllType(){
		return diamondparmcalculationMapper.getAllType();
	}

	@Override
	public List<HashMap<String, Object>> getAllspec(String codevalue) {
		return diamondparmcalculationMapper.getAllspec(codevalue);
	}


}
